import Menu from "./Menu";
import Utils from "../utils";

export default class SplashScreen extends Menu{

    constructor() {
        super();
        var t = new Laya.Sprite;
        var n = Utils.createBitmap("white");
        n.scaleX = (100 + GameConst.SCREEN_W) / 50;
        n.scaleY = (100 + GameConst.FULL_SCREEN_H) / 50;
        n.x = n.y = -50;
        n.pivotX = 0;
        n.pivotY = 0;
        t.addChild(n);
        this.sprite = t;
        var r = Utils.createBitmap("zibbo_logo");
        r.pivotX = r.width / 2;
        r.pivotY = r.height / 2;
        t.addChild(r);
        r.x = GameConst.SCREEN_W / 2;
        r.y = GameConst.FULL_SCREEN_H / 2 - 60;
        this.logo = r
    }

    show() {
        super.show();
        Laya.Tween.clearAll(this.logo);
        this.logo.scaleX = this.logo.scaleY = .85;
        Laya.Tween.to(this.logo, {
            scaleX: 1,
            scaleY: 1
        }, 300, Laya.Ease.circOut);
        Laya.Tween.to({
            scaleX: this.logo.scaleX,
            scaleY: this.logo.scaleY
        }, 400, Laya.Ease.quadIn,Laya.Handler.create(this,this.onAnimEnd));
        
    };
    onAnimEnd () {
        MenuManager.instance.show(MenuManager.instance.mainMenu, true);
    };
    onDown(t, n) {
        super(t, n);
        splashScreenData.action();
    };
}
